<p>This rule raises an issue when code uses <code>window</code>, <code>self</code>, or <code>global</code> to access the global object, except for
environment-specific APIs and events.</p>
<h2>Why is this an issue?</h2>
<p><code>globalThis</code> is the standardized way to access the global object across all JavaScript environments. Before <code>globalThis</code>,
developers had to use different global references depending on the environment:</p>
<ul>
  <li> <code>window</code> in browsers </li>
  <li> <code>global</code> in Node.js </li>
  <li> <code>self</code> in Web Workers </li>
</ul>
<p>This created compatibility issues when code needed to run in multiple environments. Using environment-specific globals makes code less portable and
harder to maintain.</p>
<p><code>globalThis</code> was introduced in ES2020 as a unified solution that works consistently across all JavaScript environments. It provides the
same global object reference regardless of whether your code runs in a browser, Node.js, or Web Worker.</p>
<p>Using <code>globalThis</code> makes your code more future-proof and eliminates the need for environment detection when accessing global
properties.</p>
<h3>What is the potential impact?</h3>
<p>Using environment-specific global references reduces code portability and can cause runtime errors when code is moved between different JavaScript
environments. This makes applications harder to maintain and test across different platforms.</p>
<h3>How to fix?</h3>
<p>Replace <code>window</code> with <code>globalThis</code> when accessing global properties or the global object itself.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const config = window.APP_CONFIG; // Noncompliant
window.myGlobalVar = 'value'; // Noncompliant
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const config = globalThis.APP_CONFIG;
globalThis.myGlobalVar = 'value';
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-global-this.md">prefer-global-this</a> </li>
  <li> MDN - globalThis - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis">Complete documentation
  for the globalThis global property</a> </li>
  <li> ECMAScript 2020 globalThis proposal - <a href="https://github.com/tc39/proposal-global">The original TC39 proposal that introduced
  globalThis</a> </li>
</ul>
<h3>Standards</h3>
<ul>
  <li> ECMAScript 2020 (ES11) - <a href="https://262.ecma-international.org/11.0/#sec-globalthis">ECMAScript specification for globalThis</a> </li>
</ul>
